{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bc4742c1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-05-15T10:22:06.425213Z",
     "iopub.status.busy": "2025-05-15T10:22:06.424213Z",
     "iopub.status.idle": "2025-05-15T10:22:06.435216Z",
     "shell.execute_reply": "2025-05-15T10:22:06.434214Z",
     "shell.execute_reply.started": "2025-05-15T10:22:06.425213Z"
    }
   },
   "outputs": [],
   "source": [
    "import os\n",
    "from pathlib import Path\n",
    "import sys\n",
    "os.makedirs('figures/', exist_ok=True)\n",
    "# set the environment variable for the current process\n",
    "os.environ[\"DATA_ROOT\"] = \"D:/Users/Paschalis/phd/data/\"\n",
    "\n",
    "repo_root = Path.cwd().parent\n",
    "# point to src directory for imports\n",
    "sys.path.insert(0, str(repo_root / \"src\"))\n",
    "\n",
    "repo_root = Path.cwd().parent\n",
    "# point to src directory for imports\n",
    "sys.path.insert(0, str(repo_root / \"src\"))\n",
    "os.makedirs('figures/', exist_ok=True)\n",
    "\n",
    "# custom colorblind-friendly palette based on Okabe-Ito\n",
    "from connecting_people.viz import set_palette\n",
    "set_palette()\n",
    "\n",
    "data_root = Path(os.environ[\"DATA_ROOT\"])\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "np.random.seed(42)\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "# from scripts.humans_wiki_palette import set_palette, colorblind_palette\n",
    "# set_palette()\n",
    "import networkx as nx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "612c697e-a74d-4727-94d9-6f1f65cb2b88",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-05-15T08:30:27.283966Z",
     "iopub.status.busy": "2025-05-15T08:30:27.283966Z",
     "iopub.status.idle": "2025-05-15T08:30:27.309814Z",
     "shell.execute_reply": "2025-05-15T08:30:27.309814Z",
     "shell.execute_reply.started": "2025-05-15T08:30:27.283966Z"
    }
   },
   "outputs": [],
   "source": [
    "def load_data(file_path):\n",
    "    \"\"\"Load the dataset from CSV and return the DataFrame.\"\"\"\n",
    "    return pd.read_csv(Path(file_path), encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d69c359c-29b3-462b-869e-6c52537b3913",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-05-15T08:30:27.312323Z",
     "iopub.status.busy": "2025-05-15T08:30:27.309814Z",
     "iopub.status.idle": "2025-05-15T08:30:41.753652Z",
     "shell.execute_reply": "2025-05-15T08:30:41.753652Z",
     "shell.execute_reply.started": "2025-05-15T08:30:27.312323Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Source</th>\n",
       "      <th>YOB_S</th>\n",
       "      <th>COB_S</th>\n",
       "      <th>field_of_human_activity</th>\n",
       "      <th>Target</th>\n",
       "      <th>YOB_T</th>\n",
       "      <th>COB_T</th>\n",
       "      <th>field_of_human_activity_T</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Stephen A. Douglas</td>\n",
       "      <td>1813.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Mary Todd Lincoln</td>\n",
       "      <td>1818.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>John Wilkes Booth</td>\n",
       "      <td>1838.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Dramaturgical Arts</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Thomas Lincoln</td>\n",
       "      <td>1778.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Samuel Lincoln</td>\n",
       "      <td>1622.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Source   YOB_S  COB_S field_of_human_activity              Target  \\\n",
       "0  Abraham Lincoln  1809.0   19.0        Government & Law  Stephen A. Douglas   \n",
       "1  Abraham Lincoln  1809.0   19.0        Government & Law   Mary Todd Lincoln   \n",
       "2  Abraham Lincoln  1809.0   19.0        Government & Law   John Wilkes Booth   \n",
       "3  Abraham Lincoln  1809.0   19.0        Government & Law      Thomas Lincoln   \n",
       "4  Abraham Lincoln  1809.0   19.0        Government & Law      Samuel Lincoln   \n",
       "\n",
       "    YOB_T  COB_T field_of_human_activity_T  \n",
       "0  1813.0   19.0          Government & Law  \n",
       "1  1818.0   19.0          Government & Law  \n",
       "2  1838.0   19.0        Dramaturgical Arts  \n",
       "3  1778.0   18.0              Applied Arts  \n",
       "4  1622.0   17.0          Government & Law  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input_file_path = Path(data_root / \"connecting_people2/experiments_filters/exp4/df_final2.csv\")\n",
    "connections_df = load_data(input_file_path)\n",
    "connections_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f6a00db5",
   "metadata": {},
   "outputs": [],
   "source": [
    "def clean_and_cast_types(df):\n",
    "    # sanity check, current df is already cleaned and filtered\n",
    "    \"\"\"Remove rows with missing values and cast columns to integer where applicable.\"\"\"\n",
    "    df = df.dropna(subset=['COB_T', 'field_of_human_activity_T']).copy()\n",
    "    df.loc[:, ['YOB_S', 'YOB_T', 'COB_S', 'COB_T']] = df[['YOB_S', 'YOB_T', 'COB_S', 'COB_T']].astype(int)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2dfdcacb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Source</th>\n",
       "      <th>YOB_S</th>\n",
       "      <th>COB_S</th>\n",
       "      <th>field_of_human_activity</th>\n",
       "      <th>Target</th>\n",
       "      <th>YOB_T</th>\n",
       "      <th>COB_T</th>\n",
       "      <th>field_of_human_activity_T</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Stephen A. Douglas</td>\n",
       "      <td>1813.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Mary Todd Lincoln</td>\n",
       "      <td>1818.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>John Wilkes Booth</td>\n",
       "      <td>1838.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Dramaturgical Arts</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Thomas Lincoln</td>\n",
       "      <td>1778.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Abraham Lincoln</td>\n",
       "      <td>1809.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>Samuel Lincoln</td>\n",
       "      <td>1622.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Source   YOB_S  COB_S field_of_human_activity              Target  \\\n",
       "0  Abraham Lincoln  1809.0   19.0        Government & Law  Stephen A. Douglas   \n",
       "1  Abraham Lincoln  1809.0   19.0        Government & Law   Mary Todd Lincoln   \n",
       "2  Abraham Lincoln  1809.0   19.0        Government & Law   John Wilkes Booth   \n",
       "3  Abraham Lincoln  1809.0   19.0        Government & Law      Thomas Lincoln   \n",
       "4  Abraham Lincoln  1809.0   19.0        Government & Law      Samuel Lincoln   \n",
       "\n",
       "    YOB_T  COB_T field_of_human_activity_T  \n",
       "0  1813.0   19.0          Government & Law  \n",
       "1  1818.0   19.0          Government & Law  \n",
       "2  1838.0   19.0        Dramaturgical Arts  \n",
       "3  1778.0   18.0              Applied Arts  \n",
       "4  1622.0   17.0          Government & Law  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "connections_df = clean_and_cast_types(connections_df)\n",
    "connections_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "315cdba0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Average Temporal Distance of Links: 33.68 years\n",
      "Median Temporal Distance of Links: 12.00 years\n"
     ]
    }
   ],
   "source": [
    "# calculate the average temporal distance of links\n",
    "temp_distances_years = connections_df.copy()\n",
    "temp_distances_years['temporal_distance_years'] = abs(temp_distances_years['YOB_T'] - temp_distances_years['YOB_S'])\n",
    "\n",
    "average_temp_distance = temp_distances_years['temporal_distance_years'].mean()\n",
    "median_temp_distance = temp_distances_years['temporal_distance_years'].median()\n",
    "print(f\"Average Temporal Distance of Links: {average_temp_distance:.2f} years\")\n",
    "print(f\"Median Temporal Distance of Links: {median_temp_distance:.2f} years\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "87d216a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>COB_S</th>\n",
       "      <th>field_of_human_activity</th>\n",
       "      <th>COB_T</th>\n",
       "      <th>field_of_human_activity_T</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-5.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-5.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>Government &amp; Law</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-5.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>Humanities &amp; Philosophy</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-5.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>Military</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-5.0</td>\n",
       "      <td>Applied Arts</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>Science</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   COB_S field_of_human_activity  COB_T field_of_human_activity_T  count\n",
       "0   -5.0            Applied Arts   -5.0              Applied Arts      4\n",
       "1   -5.0            Applied Arts   -5.0          Government & Law      3\n",
       "2   -5.0            Applied Arts   -5.0   Humanities & Philosophy      6\n",
       "3   -5.0            Applied Arts   -5.0                  Military      3\n",
       "4   -5.0            Applied Arts   -5.0                   Science      1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# confucius_business_mask_source = ~((connections_df['Source'] == 'confucius') & (connections_df['cluster'] == 'Business'))\n",
    "# suntzu_business_mask_source = ~((connections_df['Source'] == 'sun tzu') & (connections_df['cluster'] == 'Business'))\n",
    "# confucius_business_mask_target = ~((connections_df['Target'] == 'confucius') & (connections_df['cluster_T'] == 'Business'))\n",
    "# suntzu_business_mask_target = ~((connections_df['Target'] == 'sun tzu') & (connections_df['cluster_T'] == 'Business'))\n",
    "# connections_df = connections_df[confucius_business_mask_source & confucius_business_mask_target]\n",
    "# connections_df = connections_df[suntzu_business_mask_source & suntzu_business_mask_target]\n",
    "connections_df = connections_df.groupby(['COB_S', 'field_of_human_activity', 'COB_T', 'field_of_human_activity_T']).size().reset_index(name='count')\n",
    "connections_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fefa406b",
   "metadata": {},
   "outputs": [],
   "source": [
    "connections_df_copy = connections_df.copy()\n",
    "connections_df_copy = connections_df_copy.rename(columns={'COB_S': 'Source_Century', 'COB_T': 'Target_Century', 'field_of_human_activity': 'Source_Category', 'field_of_human_activity_T': 'Target_Category'})\n",
    "connections_df_copy = connections_df_copy.rename(columns={'count': 'n_connections'})\n",
    "connections_df_copy.to_parquet(Path(data_root / \"connecting_people2/graph_category_century2.parquet\"), engine=\"pyarrow\", index=False, compression=\"gzip\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ab47de34",
   "metadata": {},
   "outputs": [],
   "source": [
    "# normalize the count of connections\n",
    "# 1) total weight W\n",
    "# W = connections_df_copy['n_connections'].sum()\n",
    "\n",
    "# 2) outgoing total (row sums)\n",
    "row_totals = connections_df_copy.groupby(['Source_Century', 'Source_Category'])['n_connections'].sum().reset_index(name='row_total')\n",
    "\n",
    "# 3) incoming total (columns sums)\n",
    "col_total = connections_df_copy.groupby(['Target_Century', 'Target_Category'])['n_connections'].sum().reset_index(name='col_total')\n",
    "\n",
    "normal_connections_outgoing = connections_df_copy.merge(row_totals, on=['Source_Century', 'Source_Category'])\n",
    "normal_connections_outgoing['n_connections_norm_outgoing'] = normal_connections_outgoing['n_connections'] / normal_connections_outgoing['row_total']\n",
    "\n",
    "# normal_connections_outgoing.drop(columns=['row_total'], inplace=True)\n",
    "normal_connections_outgoing.to_parquet(Path(data_root / \"connecting_people2/graph_category_century_normalized_outgoing2.parquet\"), engine=\"pyarrow\", index=False, compression=\"gzip\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "97b66948",
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_connections_incoming = connections_df_copy.merge(col_total, on=['Target_Century', 'Target_Category'])\n",
    "normal_connections_incoming['n_connections_norm_incoming'] = normal_connections_incoming['n_connections'] / normal_connections_incoming['col_total']\n",
    "# normal_connections_incoming.drop(columns=['col_total'], inplace=True)\n",
    "normal_connections_incoming.to_parquet(Path(data_root / \"connecting_people2/graph_category_century_normalized_incoming2.parquet\"), engine=\"pyarrow\", index=False, compression=\"gzip\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "87f9b8a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def create_directed_network(df, weight_col):\n",
    "    \"\"\"Create a directed network graph from the DataFrame.\"\"\"\n",
    "    G = nx.DiGraph()\n",
    "    for _, row in df.iterrows():\n",
    "        source_node = f\"{row['Source_Century']}_{row['Source_Category']}\"\n",
    "        target_node = f\"{row['Target_Century']}_{row['Target_Category']}\"\n",
    "        weight = row[weight_col]\n",
    "        if G.has_edge(source_node, target_node):\n",
    "            G[source_node][target_node]['weight'] += weight\n",
    "        else:\n",
    "            G.add_edge(source_node, target_node, weight=weight)\n",
    "    return G\n",
    "\n",
    "G_dir_outg_norm = create_directed_network(normal_connections_outgoing, weight_col='n_connections_norm_outgoing')\n",
    "G_dir_incm_norm = create_directed_network(normal_connections_incoming, weight_col='n_connections_norm_incoming')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "963895e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Network Metrics (weighted outgoing connections):\n",
      "num_nodes: 226\n",
      "num_edges: 16852\n",
      "density: 0.3314060963618486\n",
      "avg_degree: 149.13274336283186\n",
      "avg_edge_weight: 0.013410871113220982\n",
      "\n",
      "\n",
      "Network Metrics (weighted incoming connections):\n",
      "num_nodes: 226\n",
      "num_edges: 16852\n",
      "density: 0.3314060963618486\n",
      "avg_degree: 149.13274336283186\n",
      "avg_edge_weight: 0.013232850700213624\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "def analyze_network(G):\n",
    "    \"\"\"Analyze the network and return key metrics.\"\"\"\n",
    "    num_nodes = G.number_of_nodes()\n",
    "    num_edges = G.number_of_edges()\n",
    "    density = nx.density(G)\n",
    "    avg_degree = np.mean([d for n, d in G.degree()])\n",
    "    \n",
    "    # Calculate average edge weight\n",
    "    if nx.is_weighted(G):\n",
    "        avg_edge_weight = np.mean([d['weight'] for u, v, d in G.edges(data=True)])\n",
    "    else:\n",
    "        avg_edge_weight = None  # or set to 1 if edges are unweighted\n",
    "    \n",
    "    return {\n",
    "        'num_nodes': num_nodes,\n",
    "        'num_edges': num_edges,\n",
    "        'density': density,\n",
    "        'avg_degree': avg_degree,\n",
    "        'avg_edge_weight': avg_edge_weight\n",
    "    }\n",
    "\n",
    "network_metrics_outg = analyze_network(G_dir_outg_norm)\n",
    "print(\"Network Metrics (weighted outgoing connections):\")\n",
    "for key, value in network_metrics_outg.items():\n",
    "    print(f\"{key}: {value}\")\n",
    "print(\"\\n\")\n",
    "\n",
    "network_metrics_incm = analyze_network(G_dir_incm_norm)\n",
    "print(\"Network Metrics (weighted incoming connections):\")\n",
    "for key, value in network_metrics_incm.items():\n",
    "    print(f\"{key}: {value}\")\n",
    "    \n",
    "# nx.write_gexf(G_dir_outg_norm, 'netowkr_outgoing_connections.gexf')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "bio2bio",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
